package ezXpns.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import ezXpns.BudgetChange;
import ezXpns.storage.queries.DateRangeQuery;

import java.util.Date;
import java.util.Calendar;


//@author A0086934R
public class DateRangeQueryTest {

	@SuppressWarnings("deprecation")
	@Test
	public void testConstructor() {
		Date dateA1 = new Date();
		Date dateA2 = new Date();
		dateA1.setDate(dateA1.getDate()-1);
		DateRangeQuery DRQ1 = new DateRangeQuery(dateA1, dateA2);
		
		assertNotNull(DRQ1);
	}
	
	@SuppressWarnings("deprecation")
	@Test
	public void testApply() {
		Date dateB1 = new Date();
		Date dateB2 = new Date();
		dateB1.setDate(dateB1.getDate()-3);
		dateB2.setDate(dateB2.getDate()-1);
		DateRangeQuery DRQ2 = new DateRangeQuery(dateB1, dateB2);
		
		assertNotNull(DRQ2);
		
		BudgetChange BC2 = new BudgetChange();
		Date dateB3 = new Date();
		BC2.setDate(dateB3);
		assertFalse(DRQ2.apply(BC2));
		
		BudgetChange BC3 = new BudgetChange();
		Date dateB4 = new Date();
		dateB4.setDate(dateB4.getDate()-2);
		BC3.setDate(dateB4);
		assertTrue(DRQ2.apply(BC3));
		
		BudgetChange BC4 = new BudgetChange();
		Date dateB5 = new Date();
		dateB5.setDate(dateB5.getDate()-4);
		BC4.setDate(dateB5);
		assertFalse(DRQ2.apply(BC4));
	}

}
